"use strict";

module.exports = {
  up: (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DATE } = Sequelize;
    return queryInterface.createTable("chat", {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comments: "唯一标识符",
      },
      from: {
        type: INTEGER,
        allowNull: false,
        comments: "用户id",
        references: {
          model: "users",
          key: "id",
        },
      },
      to: {
        type: INTEGER,
        allowNull: false,
        comments: "用户id",
        references: {
          model: "users",
          key: "id",
        },
      },
      content: {
        type: STRING,
        allowNull: false,
        comments: "内容",
      },
      created_at: {
        type: DATE,
      },
    });
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable("chat");
  },
};
